﻿@{
    ViewBag.Title = "系统数据总览";
    ViewBag.PathToBtn = "/";
    ViewBag.TextBtn = "刷新";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-3 col-md-6">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-xs-3">
                        <i class="fa fa-home fa-5x"></i>
                    </div>
                    <div class="col-xs-9 text-right">
                        <div id="divShopCount" class="huge">0</div>
                        <div>店铺数量</div>
                    </div>
                </div>
            </div>
            <a href="/Shops/List">
                <div class="panel-footer">
                    <span class="pull-left">查看详情</span>
                    <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                    <div class="clearfix"></div>
                </div>
            </a>
        </div>
    </div>
    <div class="col-lg-3 col-md-6">
        <div class="panel panel-green">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-xs-3">
                        <i class="fa fa-barcode fa-5x"></i>
                    </div>
                    <div class="col-xs-9 text-right">
                        <div id="divCommodityCount" class="huge">0</div>
                        <div>库商品数量</div>
                    </div>
                </div>
            </div>
            <a href="/CommodityLib/List">
                <div class="panel-footer">
                    <span class="pull-left">查看详情</span>
                    <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                    <div class="clearfix"></div>
                </div>
            </a>
        </div>
    </div>
    <div class="col-lg-3 col-md-6">
        <div class="panel panel-yellow">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-xs-3">
                        <i class="fa fa-shopping-cart fa-5x"></i>
                    </div>
                    <div class="col-xs-9 text-right">
                        <div id="divOrdersCount" class="huge">0</div>
                        <div>订单数</div>
                    </div>
                </div>
            </div>
            <a href="/Orders/List">
                <div class="panel-footer">
                    <span class="pull-left">查看详情</span>
                    <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                    <div class="clearfix"></div>
                </div>
            </a>
        </div>
    </div>
    <div class="col-lg-3 col-md-6">
        <div class="panel panel-red">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-xs-3">
                        <i class="fa fa-share-alt fa-5x"></i>
                    </div>
                    <div class="col-xs-9 text-right">
                        <div id="divCouponCount" class="huge">0</div>
                        <div>优惠券数量</div>
                    </div>
                </div>
            </div>
            <a href="/Coupon/List">
                <div class="panel-footer">
                    <span class="pull-left">查看详情</span>
                    <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                    <div class="clearfix"></div>
                </div>
            </a>
        </div>
    </div>
</div>
<!-- /.row -->
@section javascript{
    <script type="text/javascript">
        $(function() {
            getShopCount();
            getCommodityCount();
            getOrderCount();
            getCouponCount();

            $("#ContentHeadBtn").click(function () {
                getShopCount();
                getCommodityCount();
                getOrderCount();
                getCouponCount();
            });
        });

        function getShopCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/Shops/GetCount",
                data: {},
                success: function (info) {
                    $("#divShopCount").html(info);
                }
            });
        }

        function getCommodityCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/CommodityLib/GetCount",
                data: {},
                success: function (info) {
                    $("#divCommodityCount").html(info);
                }
            });
        }

        function getOrderCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/Orders/GetCount",
                data: {},
                success: function (info) {
                    $("#divOrdersCount").html(info);
                }
            });
        }

        function getCouponCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/Coupon/GetCount",
                data: {},
                success: function (info) {
                    $("#divCouponCount").html(info);
                }
            });
        }
    </script>
}